<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="static/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="static/bootstrap/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="static/easyui/themes/icon.css">
<link rel="stylesheet" href="static/css/style.css" />
<link rel="stylesheet" href="static/css/tcommon.css" />
<script src="static/jquery/jquery-1.12.4.js"></script>
<script src="static/bootstrap/js/bootstrap.js"></script>
<script src="static/easyui/jquery.easyui.min.js"></script>
<script src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="static/excel/datagrid-export.js"></script>
<title>民工工资</title>

</head>

<body>
	<div class="content-container" data-options="region:'center'">
		<div class="panel-header">
			<div class="panel-title">民工工资列表</div>
		</div>
		<table id="pro_table" class="easyui-datagrid" style="height: 100%">
		</table>

		<div id="pro_tb">
			<div class="search-container">
				<div class="search-input">
					姓名：
					<input id="name" class="easyui-textbox" />
				</div>
				<div class="search-input">
					工号：
					<input id="jobno" class="easyui-textbox" />
				</div>
				<div class="search-input">
					<a href="#" class="easyui-linkbutton" iconCls="icon-search" id="search">搜索</a>
				</div>
				<div class="search-input">
					<a href="javascript:;" class="easyui-linkbutton" onclick="Export();">导出Excel</a>
				</div>
			</div>
		</div>
	</div>
</body>
<script>
	var currentPro;
	var jobno = "";
	var name = "";

	function Export(){　　　　
		$('#pro_table').datagrid('toExcel', {
		    filename: '民工工资-'+formatDate(new Date())+'.xls',
		    worksheet: 'Worksheet'
		});
	}
	
	$("#search").click(function() {
		jobno = $("#jobno").textbox('getValue');
		name = $("#name").textbox('getValue');
		refreshProTable();
	});
	$(document).ready(function() {
		$('#pro_table').datagrid({
			rownumbers : true,
			singleSelect : true,
			pagination : true,
			fitColumns : false,
			border : false,
			striped : true,
			toolbar : '#pro_tb',
			url : "jobbersuser.do",
			method : 'get',
			queryParams : {
				jobno : jobno,
				name : name
			},
			onSelect : function(index,row) {
				currentPro = row;
			},
			onDblClickRow : function(index,row) {
				currentPro = row;
				updatepro();
			},
			columns : [ [ {
				field : 'username',
				title : '姓名',
				width : ''
			},{
				field : 'projectitemname',
				title : '项目名',
				width : ''
			},{
				field : 'date',
				title : '施工日期',
				width : '',
				formatter : formatDate
			},{
				field : 'departmentname',
				title : '部门名称',
				width : ''
			},{
				field : 'cnt',
				title : '工日',
				width : ''
			},{
				field : 'salary',
				title : '日薪(元)',
				width : ''
			},{
				field : 'money',
				title : '金额(元)',
				width : ''
			} ] ]
		});
	});
	function refreshProTable() {
		$('#pro_table').datagrid('load', {
			jobno : jobno,
			name : name
		});
	}
	function formatDate(time) {
		var date = new Date(time);
		var year = date.getFullYear(),month = date.getMonth() + 1, //月份是从0开始的
		day = date.getDate(),hour = date.getHours(),min = date.getMinutes(),sec = date.getSeconds();
		var newTime = year + '-' + month + '-' + day;
		return newTime;
	}
</script>

</html>